package com.swt.controller;

import com.swt.common.utils.QiNiuYunUpFileUtils;
import com.swt.common.vo.ResponseVo;
import com.swt.domain.Admin;
import com.swt.domain.TbUser;
import com.swt.service.TbUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description
 * @Author swt
 * @Date 2022/5/17
 */
@RestController
@RequestMapping("/TbUser")
public class TbUserController {
    @Autowired
    public TbUserService tbUserService;
    @PostMapping("/{count}/{size}")
    public ResponseVo pageTbUser(@PathVariable Integer count,
                                 @PathVariable Integer size,
                                 @RequestBody(required = false) TbUser tbUser){
        System.out.println(tbUser);
        return ResponseVo.SUCCESS(tbUserService.pageTbUser(count,size,tbUser));

    }
    @DeleteMapping("/{id}")
    public ResponseVo deleteTbUser(@PathVariable String id){
        return tbUserService.delectTbUser(id)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @GetMapping("/{id}")
    public ResponseVo selectTbUserById(@PathVariable String id){
        return ResponseVo.SUCCESS(tbUserService.selectbyTbUser(id));
    }
    @PostMapping
    public ResponseVo insertTbUser(@RequestBody TbUser s){
        return tbUserService.inserTbUser(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @PutMapping
    public ResponseVo updateTbUser(@RequestBody TbUser s){
        return tbUserService.updateTbUser(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @PostMapping("/upload")
    public ResponseVo upLoadTbUserImg(MultipartFile file){
        System.out.println(file);
        return QiNiuYunUpFileUtils.getUpLoad(file);
    }


}

